from selenium import webdriver
from selenium.webdriver.common.by import By
from time import sleep
import unittest
from ui_auto.config .config import *
from ui_auto.public.utils.read_ini import Read_ini
from ui_auto.public.pages.basepage import BasePage
from ui_auto.data.page_elem import Analysysdata_elem
from selenium.webdriver.support.wait import WebDriverWait


class Add_rloe(BasePage):
    def test_add_rloe(self):
        role_name="测试账户101"
        ea=BasePage.get_driver()
        elem5 = BasePage.search_elem(['XPATH', Analysysdata_elem.setting_btn])
        BasePage.click(elem5)
        elem6 = BasePage.search_elem(['XPATH', Analysysdata_elem.role_members_btn])
        BasePage.click(elem6)
        try:
            elem7=BasePage.search_elem(Analysysdata_elem.role_man_text)
            value=BasePage.text(elem7)
            self.assertEqual(value,"角色管理")
        except Exception as error:
            print(error)
        elem1 = BasePage.search_elem(['XPATH', Analysysdata_elem.add_role_btn])
        BasePage.click(elem1)
        elem2 = BasePage.search_elem(['XPATH', Analysysdata_elem.input])
        BasePage.sendkeys(elem2, role_name)
        elem3 = BasePage.search_elem(['XPATH', Analysysdata_elem.next_step_btn])
        BasePage.click(elem3)
        WebDriverWait(ea, 10).until(lambda _: ea.find_element(By.XPATH, Analysysdata_elem.function_setting_text))
        elem_frame=BasePage.search_elem(['XPATH',"//div[@class='ans-modal-box-content-wrapper']"])
        ea.switch_to.frame(elem_frame)
        elem4=BasePage.search_elem(['XPATH',Analysysdata_elem.function_switch_btn("用户旅程&策略管理")])
        BasePage.click(elem4)
        # elem5 = BasePage.search_elem(['XPATH',Analysysdata_elem.function_switch_btn("用户&权限")])
        # BasePage.click(elem5)
        # elem6 = BasePage.search_elem(['XPATH',Analysysdata_elem.function_switch_btn("系统配置")])
        # BasePage.click(elem6)
        # elem7 = BasePage.search_elem(['XPATH',Analysysdata_elem.next_step_btn])
        # BasePage.click(elem7)


